/* wod.t   WORK ORDER DELETE TRIGGER                                          */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.1.1.1 $                                                           */
/*V8:ConvertMode=NoConvert                                                    */
/* Revision: 1.1       BY: Julie Milligan       DATE: 05/13/02   ECO: *P06V*  */
/* $Revision: 1.1.1.1 $      BY: Inna Fox             DATE: 06/13/02   ECO: *P04Z*  */
/******************************************************************************/

TRIGGER PROCEDURE FOR DELETE OF wo_mstr.

/*fdn*/    {mfdeclre.i }
/*fdn*/    define new shared work-table wf_old_wo_mstr like wo_mstr.

/* Remove any flow schedule details associated with current work order */
for first flsd_det exclusive-lock where
   flsd_flow_wo_nbr = wo_nbr and
   flsd_flow_wo_lot = wo_lot: end.
if available flsd_det then delete flsd_det.

	HK:
	do:
        if not can-find ( first dt_mstr where dt_table = "wo_mstr" and dt_type = "DEL" ) then leave HK.
        
        if not can-find ( first wf_old_wo_mstr ) then do:
            create wf_old_wo_mstr.
            if recid(wf_old_wo_mstr)= -1 then .
        end.
        
        buffer-copy wo_mstr to wf_old_wo_mstr no-error.

        for first dt_mstr no-lock where dt_table = "wo_mstr" and dt_type = "DEL" :
        
			run value(global_user_lang_dir + "hk/hktrigdel.p")
       			"wf_old_wo_mstr"		/*old buffer*/
       			""						/*new buffer*/
       			dt_table				/*table name*/
       			""						/*field name*/
       			dt_type					/*type*/
       			recid(wo_mstr)			/*key*/	
       			wo_mstr.wo_lot			/*key1*/
       			""						/*key2*/
       			""						/*key3*/
       			""						/*key4*/
       			""						/*key5*/
       			""						/*key6*/
       			""						/*key7*/
       			""						/*key8*/
       			.
			
        end.
	end.
